<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>MySQL 5.5 源码安装 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>MySQL 5.5 源码安装</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/MySQL/">MySQL</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先安装必要的库</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum install -y gcc*</div></pre></td></tr></table></figure>
<h2 id="首先安装cmake"><a href="#首先安装cmake" class="headerlink" title="首先安装cmake"></a>首先安装cmake</h2><ol>
<li>支持yum安装</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum install -y cmake</div></pre></td></tr></table></figure>
<ol>
<li>也可以源码安装</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/src</div><div class="line"><span class="comment">#下载cmake</span></div><div class="line">wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz</div><div class="line">tar zxvf cmake-2.8.7.tar.gz</div><div class="line"><span class="built_in">cd</span> cmake-2.8.7</div><div class="line"><span class="comment">#安装cmake</span></div><div class="line">./configure</div><div class="line">make</div><div class="line">make install</div></pre></td></tr></table></figure>
<h2 id="安装-MySQL"><a href="#安装-MySQL" class="headerlink" title="安装 MySQL"></a>安装 MySQL</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="http://dev.mysql.com/downloads" target="_blank" rel="external">官网</a>下载mysql5.5版本Linux系统源码包。</p>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">groupadd mysql</div><div class="line">useradd -g mysql mysql</div><div class="line">tar zxvf mysql-5.2.25.tar.gz</div><div class="line"><span class="built_in">cd</span> mysql-5.2.25</div></pre></td></tr></table></figure>
<ul>
<li>cmake：默认情况下安装，安装目录为/usr/local/mysql ，数据目录为/usr/local/mysql/data</li>
<li>也可以指定参数安装，如指定UTF8，数据引擎等</li>
<li>具体参照<a href="https://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html" target="_blank" rel="external">官方说明文档</a></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">cmake -DCMAKE_INSTALL_PREFIX=/usr/<span class="built_in">local</span>/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1</div><div class="line">make &amp;&amp; make install</div><div class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/mysql</div><div class="line">chown -R mysql:mysql /usr/<span class="built_in">local</span>/mysql</div><div class="line">./scripts/mysql_install_db --user=mysql -datadir=/mysql/data</div><div class="line"><span class="comment">#此处如不指定datadir，到启动时会报错</span></div><div class="line">chown -R root .</div><div class="line">chown -R mysql data</div><div class="line">cp support-files/my-medium.cnf /etc/my.cnf</div><div class="line">bin/mysqld_safe --user=mysql &amp;amp;</div><div class="line"><span class="comment"># Next command is optional</span></div><div class="line">cp support-files/mysql.server /etc/init.d/mysqld</div><div class="line">chmod +x /etc/init.d/mysqld</div><div class="line">/etc/init.d/mysqld start</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;到此，安装完成。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/MySQL/2. MySQL 5.5 源码安装/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
